package com.example.compose_learn

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Button
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.example.compose_learn.compose.ComposePage
import com.example.compose_learn.ui.theme.ComposableTheme
import com.example.compose_learn.views.AndroidViewFragment

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            ComposableTheme {
                Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding ->
                    Column(
                        modifier = Modifier
                            .padding(innerPadding)
                            .fillMaxWidth(),
                        verticalArrangement = Arrangement.Center,
                        horizontalAlignment = Alignment.CenterHorizontally
                    ) {
                        Spacer(modifier = Modifier.height(10.dp))
                        Button(onClick = {
                            AndroidViewFragment.newInstance().show(
                                supportFragmentManager,
                                "AndroidViewFragment"
                            )
                        }) {
                            Text(text = "Android view 列表", fontSize = 30.sp)
                        }
                        Spacer(modifier = Modifier.height(10.dp))
                        Button(onClick = {
                            ComposePage.newInstance().show(
                                supportFragmentManager,
                                "ComposePage"
                            )
                        }) {
                            Text(text = "Compose view 列表", fontSize = 30.sp)
                        }
                    }
                }
            }
        }
    }
}